# Maintainer: David Runge <dvzrv@archlinux.org>
# Contributor: Ray Rashif <schiv@archlinux.org>
# Contributor: galiyosha@gmail.com
# Contributor: Jon Kristian Nilsen <jokr.nilsen@gmail.com>

pkgname=libffado
pkgver=2.4.7
pkgrel=2
pkgdesc="Driver for FireWire audio devices"
arch=(loong64 x86_64)
url="http://www.ffado.org/"
license=(GPL3)
depends=(gcc-libs glibc glibmm hicolor-icon-theme libavc1394
libiec61883 libxml++ python-dbus)
makedepends=(alsa-lib dbus-c++ jack libconfig python-pyqt5 scons)
optdepends=('python-pyqt5: ffado-mixer')
provides=(libffado.so)
source=(http://www.ffado.org/files/$pkgname-$pkgver.tgz)
sha512sums=('424a9ca7ded12e72d77a50d7ddf4e50dc0d55b80d725499df7609ce60d0eac8b24a41d9b8e4e74f78bdefe114b61bd5f1ec09a6d083f4a58475e66d61153f075')
b2sums=('3c304011259ddbd35ce8fd725d38a5f50fca962981f9c5af6e377493a14985e4b96c64bcc54ba5a341028ec17dc6f2c42ce527422779f2edc6f9a1a61220cf51')

prepare() {
  cd $pkgname-$pkgver
  # fix icon name, so it's coherent with XDG desktop file name
  sed -e 's/hi64-apps-ffado/ffado-mixer/g' -i support/xdg/ffado.org-ffadomixer.desktop
  # fix id, so it's coherent with XDG desktop file name
  sed -e 's/ffado.org-ffadomixer.desktop/ffado-mixer.desktop/g' -i support/xdg/ffado-mixer.appdata.xml
}

build() {
  local python_version=$(python -c 'import sys; print(".".join(map(str, sys.version_info[:2])))')

  cd $pkgname-$pkgver
  scons PREFIX=/usr \
        DEBUG=no \
        CUSTOM_ENV=True \
        MANDIR=/usr/share/man \
        PYTHON_INTERPRETER=/usr/bin/python3 \
        PYPKGDIR=/usr/lib/python$python_version/site-packages \
        UDEVDIR=/usr/lib/udev/rules.d
}

package() {
  depends+=(libasound.so libconfig++.so libdbus-c++-1.so)

  cd $pkgname-$pkgver
  scons DESTDIR="$pkgdir" WILL_DEAL_WITH_XDG_MYSELF=True install
  install -vDm 644 support/xdg/ffado.org-ffadomixer.desktop "$pkgdir/usr/share/applications/ffado-mixer.desktop"
  install -vDm 644 support/xdg/hi64-apps-ffado.png "$pkgdir/usr/share/icons/hicolor/64x64/apps/ffado-mixer.png"
  install -vDm 644 {AUTHORS,README} -t "$pkgdir/usr/share/doc/$pkgname/"
}

# vim:set ts=2 sw=2 et:
